<?php
/*
Plugin Name: exmashup
Plugin URI: http://www.e-xtrategy.net
Description: Permettere di leggere via php un mashup rss (ottimizzato per Yahoo Pipes) ed è possibile inglobarlo all'interno di un template. Richiede Zend Framework 1.6 e Rolando2 e jQuery
Version: 1.2.0
Author: e-xtrategy
Author URI: http://www.e-xtrategy.net
*/
/*  Copyright 2009  e-xtrategy  (email : info@e-xtrategy.net)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/
header('Content-type: text/html; charset=utf-8');
require_once 'Feed.php';

//Necessarie per Rolando
//define("PATH_LIB","/home/web/rolando/");
//define('PATH_ROLANDO_HELPERS',PATH_LIB.'Rolando2/helpers/');

/* INCLUSIONE FRAMEWORK */
$R_version = 12; //R2+ZF
$ZF_version = '1.8.4';
$bNoPathLib = true; //NON definisce la costante path lib
require_once '/home/web/rolando2009/rolando.php';


define('STRURLFEED','http://pipes.yahoo.com/exlive/mashupwebsite?_render=rss');
define('STRNOMEBUFFERFILE','buffer.inc.php');
define('BUFFERPATH','wp-content/plugins/exmashup/');
define('NOMEOGGETTODOM','.Live');
define('NUMEROELEMENTILIVE','5');

function include_buffer() {
	$strResult = '';
	include ABSPATH.BUFFERPATH.STRNOMEBUFFERFILE;
	var_dump($strItems);
	$aItems = unserialize($strItems);

	$aTplReturn = array('testata' => array('tpl_type' => 'str','tpl' => ''),
							'riga' 		=> array('tpl_type' => 'str','tpl' => '<li class="[*tipo*]"><a href="[*link*]">[*titolo*]</a></li>') ,
							'fondo' 	=> array('tpl_type' => 'str','tpl' => ''));
	$oItem = new Rolando_Lister();
	$strResult .= $oItem->Lister($aItems['aItems'],$aTplReturn,$aDati);
	
	return $strResult;
}

function reload_mashup_script() {
	$strResult = '<script type="text/javascript">
		var initMashup = function () {
			setInterval(function(){
							//alert(\''.get_bloginfo('url').'/'.BUFFERPATH.'mashup.php?modoOutput=return\');
							$.get(\''.get_bloginfo('url').'/'.BUFFERPATH.'mashup.php?modoOutput=return\',function(dataPag) {
																											if (dataPag.indexOf(\'<li\')>-1) {
																												$(\''.NOMEOGGETTODOM.'\').empty();
																												$(\''.NOMEOGGETTODOM.'\').append(dataPag);
																											}
																										});
						}, 30000);
		}
		$(document).ready(initMashup);</script>';
	echo $strResult;
}